package com.xl.rentkeeper.db.orm;

import android.content.Context;

import com.xl.rentkeeper.db.orm.util.ManifestHelper;


public class DBContext {

    private DBOpenHelper openHelper;
    private Context context;
    private long uid;
    DBInterface dbInterface;
    public DBContext(Context context,long uid) {
        this.context = context;
        this.uid = uid;
        ORMap.init();
        this.openHelper = new DBOpenHelper(context,uid);
        dbInterface = new DBInterface(openHelper);
    }

    public static String getDBName(Context context,long uid) {
//        return PathConf.APP_ROOT_PATH +uid+"_"+ ManifestHelper.getDatabaseName(context);
        return uid+"_"+ ManifestHelper.getDatabaseName(context);
    }
    

    public void close() {
        if (this.openHelper != null) {
            this.openHelper.getDB().close();
        }
    }

    public DBOpenHelper getOpenHelper() {
        return openHelper;
    }

    public DBInterface getDbInterface() {
        return dbInterface;
    }

}
